package com.bytefy.core;

import java.util.ArrayList;


@SuppressWarnings("serial")
public class CallbackedList<E> extends ArrayList<E>{
	private ICallback<CallbackedList<E>> callback;
	private int interval;
	
	public CallbackedList(int interval, ICallback<CallbackedList<E>> callback) {
		this.interval = interval;
		this.callback = callback;
	}
	
	@Override
	public boolean add(E o) {
		boolean flag = super.add(o);
		if (size()>=interval && callback != null) {
			callback.call(this);
		}
		return flag;
	}
	
	

}
